package com.lwt.controller;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import com.lwt.util.Result;

/**
 * 
 * @author LWT
 *
 */
@ControllerAdvice
public class GlobalController {
	@ExceptionHandler(Exception.class)
	@ResponseStatus(HttpStatus.NOT_FOUND)
	@ResponseBody
	public Result exception1(Exception e){
		System.out.println("捕获异常前");
		e.printStackTrace();
		System.out.println("捕获异常后");
		Result rs=new Result();
		rs.setCode(4000);
		rs.setMessage("出现异常");
		return rs;	
	}
}
